#include"string.h"

namespace jyz
{
	void teat_siring1()
	{
		jyz::string s1("hello world");
		cout << s1.c_str() << endl;
		cout << s1.size() << endl;
		cout << s1[1] << endl;
		for (int i = 0; i < s1.size(); ++i)
		{
			cout << s1[i] << " ";
		}
		cout << endl;
		for (auto e : s1)
		{
			cout << e << " ";
		}
		cout << endl;
		string::iterator it1 = s1.begin();
		while (it1 != s1.end())
		{
			cout << *it1 << " ";
			++it1;
		}
		cout << endl;

	}
	void teat_siring2()
	{
		jyz::string s1("hello");
		s1.push_back('x');
		cout << s1.c_str() << endl;
		s1.append("YYY");
		cout << s1.c_str() << endl;
		s1 += 'z';
		cout << s1.c_str() << endl;
		s1 += "sss";
		cout << s1.c_str() << endl;

	}
	void teat_siring3()
	{
		jyz::string s1("hello world");
		s1.insert(5, 'x');
		cout << s1.c_str() << endl;
		s1.insert(6,"yyy");
		cout << s1.c_str() << endl;
		jyz::string s2("hello world");
		//s2.erase(5, 2);
		//cout << s2.c_str() <<endl;
		//s2.erase(5);
		//cout << s2.c_str() << endl;
	}

	void teat_siring4()
	{
		jyz::string s1("hello");
		string s2;
		s2 = s1;
		cout << s2.c_str() << endl;
		jyz::string s3 = "world";
		swap(s1, s3);
		cout << s1.c_str() << endl;
		cout << s3.c_str() << endl;
		jyz::string sub = s1.substr(3, 2);
		cout<<sub.c_str() << endl;

	}
}

int main()
{
	jyz::teat_siring3();
	return 0;
}